package com.example.concurrentprogramming8016.future.completablefuture;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

/**
 * @author liyanhao
 * @Date 2023-01-08 20:02
 * CompletableFuture thenApply
 */
public class ThenApplyDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<Integer> completableFuture = CompletableFuture.supplyAsync(() -> {
            int result = 1;
            System.out.println("一阶段:" + result);
            return result;
        }).thenApply(number->{

            int result = number * 3;
            System.out.println("二阶段:" + result);
            return result;
        });
        System.out.println("最总结果:" + completableFuture.get());

    }
}
